define(['jquery', 'bootstrap', 'frontend', 'form', 'table', 'template'], function ($, undefined, Frontend, Form, Table, Template) {
    var validatoroptions = {
        invalid: function (form, errors) {
            $.each(errors, function (i, j) {
                Layer.msg(j);
            });
        }
    };
    var Controller = {
        index: function () {

            $(document).on("click", "#J_weixin", function () {
                console.log('111');
                Frontend.api.ajax({
                    url: 'download/dodownload',
                }, function () {
                    console.log('222');
                    //__CDN__/d/download_files/TZXBS.apk
                    //window.location.href= "https://www.baidu.com/";
                    //window.location.href= "http://lj.megotw.com/uploads/TZXBS.apk";
                    window.location.href= "/uploads/TZXBS.apk";

                });

            });

            Controller.api.bindevent();
        },
        iosindex: function () {

            $(document).on("click", "#J_weixin", function () {
                //window.location.href= "http://lj.megotw.com/index/download/ios";
                window.location.href= "ios";
            });

            Controller.api.bindevent();
        },
        login: function () {

            Controller.api.bindevent();
        },
        ios: function () {

            $(document).on("click", "#btn_submit0", function () {
                //Layer.confirm(WSdata.a3_name7, {
                //    title: __(''),
                //    btn: [WSdata.queren, WSdata.quxiao] //按鈕
                //}, function (index) {
                //    $("#edit-form").submit();
                //    layer.close(index);
                //    return true;
                //}, function (index) {
                //    layer.close(index);
                //    return false;
                //});

                //var formdata = $("#edit-form").serialize();
                var x = $("#edit-form").serializeArray();
                var row = new Array();
                $.each(x, function (i, field) {
                    row[field.name] = field.value;
                });
                //content4=212
                console.log(row['content4']);
                if (row['content4'].length < 6) {
                    Frontend.api.toastr.error("请输入正确的手机号。");
                    return;
                }
                Frontend.api.ajax({
                    url: 'download/hqyzm',
                    data: {
                        content1: row['content1'],
                        content2: row['content2'],
                        content3: row['content3'],
                        content4: row['content4'],
                        content5: row['content5'],
                        content6: row['content6'],
                    },
                }, function () {

                    window.location.href= "ios2?content4=" + row['content4'];
                });

            });

            Controller.api.bindevent();
        },
        ios2: function () {
            $(document).on("click", "#btn_submit0", function () {
                var x = $("#edit-form").serializeArray();
                var row = new Array();
                $.each(x, function (i, field) {
                    row[field.name] = field.value;
                });
                Frontend.api.ajax({
                    url: 'download/ios2',
                    data: {
                        content4: row['content4'],
                        content7: row['content7'],
                    },
                }, function () {
                    window.location.href= "ios3";
                });

            });

            Controller.api.bindevent();
        },
        ios3: function () {

        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"), function (data, ret) {
                    //console.log(ret);
                    setTimeout(function () {
                        location.href = ret.url ? ret.url : "/";
                    }, 1000);
                });
            }
        }
    };
    return Controller;
});